会员商品不足

FFIB 5 years ago
parent
commit
609955cf1c
2 changed files with 4 additions and 0 deletions
  1. 3 0
      api/member_views.py
  2. 1 0
      utils/error/errno_utils.py

+ 3 - 0
api/member_views.py

@@ -199,6 +199,9 @@ def good_exchange(request):
199 199
         user.integral -= good.integral
200 200
         user.save()
201 201
 
202
+        if good.left_num <= 0:
203
+            return response(MemberGoodStatusCode.GOOD_STOCK_NOT_ENOUGH)
204
+
202 205
         good.left_num -= 1
203 206
         good.save()
204 207
 

+ 1 - 0
utils/error/errno_utils.py

@@ -68,6 +68,7 @@ class MemberGoodStatusCode(BaseStatusCode):
68 68
 
69 69
     GOOD_NO_EXCHANGE_PERMISSION = StatusCodeField(503502, 'Good No Exchange Permission', description=u'商品无兑换权限')
70 70
     GOOD_INTEGRAL_NOT_ENOUGH = StatusCodeField(503503, 'Good Integral Not Enough', description=u'商品兑换积分不足')
71
+    GOOD_STOCK_NOT_ENOUGH = StatusCodeField(503504, 'Good Integral Not Enough', description=u'商品库存不足')
71 72
 
72 73
 
73 74
 class MemberRightStatusCode(BaseStatusCode):